package com.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.entity.CommentEntity;

@Repository
public class CommentDaoImpl extends GenericDaoImpl<CommentEntity> implements
		CommentDao {

	public CommentEntity getCommentById(Integer id) {
		return getById(CommentEntity.class, id);
	}
	
	public int getMaxCommentId() {
		String hql = "select max(idComment) From CommentEntity ";
		Query query = sessionFactory.getCurrentSession().createQuery(hql);
		return (Integer) query.uniqueResult();
	}

	public List<CommentEntity> getAllComments() {
		return getAll(CommentEntity.class);
	}

}
